/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package movie;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author admin
 */
public class Film {

    public String judul_film;
    public String sinopsisFilm;
    public String trailer;
    public String poster;
    public String lokasiFilm;
    public String harga;
    public String id;
    public int count = 0;

    public Film() {
    }

    /**
     * @return the nama_film
     */
    public String getJudul_film() {
        return judul_film;
    }

    /**
     * @param nama_film the nama_film to set
     */
    public void setNama_film(String judul_film) {
        this.judul_film = judul_film;
    }

    public void insertVideo() {
        try {
            Connection connection = new connection().getDBConnection();
            Statement s = connection.createStatement();
//            String sql = "insert into PAKET values('" + idPaket + "', '" + namaPaket + "', to_Date('" + waktu + "', 'DD-MM-YY'), " + harga + ",'" + armada + "','" + fasilitas + "','" + tujuan + "'," + kuota + ")";
//            String sql = "insert into VIDEO values('" + judul_film + "','" + sinopsisFilm + "','" + lokasiFilm + "')";
            String sql = "insert into MOVIE values('" + judul_film + "','" + sinopsisFilm + "','" + lokasiFilm + "','" + trailer + "','" + poster + "','"+harga+"', '"+count+"')";
            ResultSet rs = s.executeQuery(sql);
//            JOptionPane.showMessageDialog(null, "data video berhasil disimpan");
            rs.close();
            s.close();
            connection.close();
        } catch (SQLException ex) {
//            JOptionPane.showMessageDialog(null, "data video gagal disimpan");
            Logger.getLogger(Film.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * @return the lokasiFilm
     */
    public String getLokasiFilm() {
        return lokasiFilm;
    }

    /**
     * @param lokasiFilm the lokasiFilm to set
     */
    public void setLokasiFilm(String lokasiFilm) {
        this.lokasiFilm = lokasiFilm;
    }

    /**
     * @return the sinopsisFilm
     */
    public String getSinopsisFilm() {
        return sinopsisFilm;
    }

    /**
     * @param sinopsisFilm the sinopsisFilm to set
     */
    public void setSinopsisFilm(String sinopsisFilm) {
        this.sinopsisFilm = sinopsisFilm;
    }

    /**
     * @return the trailer
     */
    public String getTrailer() {
        return trailer;
    }

    /**
     * @param trailer the trailer to set
     */
    public void setTrailer(String trailer) {
        this.trailer = trailer;
    }

    /**
     * @return the poster
     */
    public String getPoster() {
        return poster;
    }

    /**
     * @param poster the poster to set
     */
    public void setPoster(String poster) {
        this.poster = poster;
    }

    public static ArrayList lihatDataPaket() {
        ArrayList pakets = new ArrayList();
        try {
            Connection connection = new connection().getDBConnection();
            Statement s = connection.createStatement();
            String sql = "SELECT * from movie";
            ResultSet rs = s.executeQuery(sql);
            while (rs.next()) {
                Film pkt = new Film();
                pkt.judul_film = rs.getString(1);
                pkt.sinopsisFilm = rs.getString(2);
                pkt.lokasiFilm = rs.getString(3);
                pkt.trailer = rs.getString(4);
                pkt.poster = rs.getString(5);
                pkt.harga = rs.getString(6);
//                pkt.fasilitas = rs.getString(6);
//                pkt.tujuan = rs.getString(7);
//                pkt.kuota = rs.getInt(8);
                pakets.add(pkt);
            }
            rs.close();
            s.close();
            connection.close();
        } catch (SQLException e) {
        }
        return pakets;
    }
    public static ArrayList lihatDataPaket2() {
        ArrayList pakets = new ArrayList();
        try {
            Connection connection = new connection().getDBConnection();
            Statement s = connection.createStatement();
            String sql = "SELECT * from movie ORDER BY count Desc";
            ResultSet rs = s.executeQuery(sql);
            while (rs.next()) {
                Film pkt = new Film();
                pkt.judul_film = rs.getString(1);
                pkt.sinopsisFilm = rs.getString(2);
                pkt.lokasiFilm = rs.getString(3);
                pkt.trailer = rs.getString(4);
                pkt.poster = rs.getString(5);
                pkt.harga = rs.getString(6);
//                pkt.fasilitas = rs.getString(6);
//                pkt.tujuan = rs.getString(7);
//                pkt.kuota = rs.getInt(8);
                pakets.add(pkt);
            }
            rs.close();
            s.close();
            connection.close();
        } catch (SQLException e) {
        }
        return pakets;
    }

    /**
     * @return the harga
     */
    public String getHarga() {
        return harga;
    }

    /**
     * @param harga the harga to set
     */
    public void setHarga(String harga) {
        this.harga = harga;
    }
}
